<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	    		xmlns:ui="http://java.sun.com/jsf/facelets"
	  			xmlns:h="http://java.sun.com/jsf/html"
	  			xmlns:f="http://java.sun.com/jsf/core"                
                xmlns:cs="http://myfaces.apress.com/custom"
				template="/WEB-INF/layouts/standard.xhtml"
				xmlns:a4j="http://richfaces.org/a4j"
				xmlns:rich="http://richfaces.org/rich"
				xmlns:bf="http://www.bssmanager.com/jsf"
				xmlns:c="http://java.sun.com/jstl/core"
				xmlns:fn="http://www.bss.com/functions">

	<ui:define name="headIncludes">
		<style>
			.modalPanelInternal {
				width:100%;
				height:300px;
				overflow:auto;
				margin: 0px;
				padding: 0px;
			}
			.rc11 {
				border:0px;
			}
			
			.rc12 {
				color: white;
			}
			
			.rc13 {
				width:90px; 
				height: 30px; 
				border:0px;
			}
			td {
				vertical-align: top;
			}
			.rc14 {
				width: 180px;
			}			
			
			.cls12 {
				width:50%;
				height:100%;
				vertical-align: top;				
			}
													
			.rc {
				margin:0px;
				border:0px;
			}			
			.cc {
				width:40px; 
				height: 25px; 
				border:0px;
				font-size: 8pt;
			}
			
			.ccInner {
				width:40px;
				height: 100%;
			}
			.btnImgStyle {
				width: 25px; 
				height: 25px;
			}

			.ht1 {
				color: white;
				font-weight: bold;
				font-size: 12pt;
				width: 20px;
				margin-right: 15px;
			}
			.link1 {
				color: white;
				font-weight: bold;
				text-decoration: none;
			}
			
		</style>

		<script type="text/javascript"><!--
			var childW = null;
	
			function launchChildW() {				
			  var url = "${request.contextPath}/webcam2/webcam.jsp";			   
			  wopts  = 'width=350,height=300,resizable=1,alwaysRaised=1,scrollbars=1,modal=yes';	
			  if (window.showModalDialog) {
					window.showModalDialog(url,self,wopts);
				} else {
					window.open(url,'Popup',wopts);
				}
			}
					
			function setImage(im) {
				try{
				loadClickedImage();
				}catch(e) {
				alert("Errror on setttt "+e);
					}							            
			}	
			
		--></script>
		
	</ui:define>
	
	<ui:define name="formheader">
		<h2>Update Current Patient</h2>
	</ui:define>	
	
	<ui:define name="content">
	
	
	
	<h:form prependId="false">
					
					<a4j:jsFunction name="loadClickedImage" reRender="imgctrl22" limitToList="true"/>
					
	<div align="left">
		<h:panelGroup>
			<bf:admissionSelector controller="#{updateAdmissionController}" selectMethod="select" reRender="selectedPatient,selectedPatientX,id11,id22" idd="md"/>
		</h:panelGroup>										
	</div>
	

				<rich:panel style="border:0;width:100%; display: #{updateAdmissionController.model.id eq 0 ? 'none':'block'}" id="selectedPatientX">
					<f:facet name="header">
						<h:outputText value="Patient Details"/>
					</f:facet>
							<h:panelGrid columns="4">
								
								<h:outputLabel value="Name: "/>
								<h:outputText value="#{updateAdmissionController.model.patient.name}" />
								<h:outputLabel value="ID: "/>
								<h:outputText value="#{updateAdmissionController.model.id}" />
								<h:outputLabel value="Checked-in On: "/>
								<h:outputText value="#{updateAdmissionController.model.dateOfAdmission}">
									<f:convertDateTime pattern="dd MMM yyyy HH:MM" timeZone="#{preferences.timeZone.ID}"  />
								</h:outputText>
							</h:panelGrid>
				</rich:panel>

	<h:panelGrid style="border:0;width:100%; display: #{updateAdmissionController.model.id eq 0 ? 'none':'block'}" columns="2" width="100%" id="selectedPatient">
				<rich:panel style="border:0">
					<f:facet name="header">
						<h:outputText value="General Details"/>
					</f:facet>
							<h:panelGrid columns="2" columnClasses="cls12">	
								<h:panelGroup>	
									<h:outputLabel value="First Name" />
									<h:outputLabel value="*" styleClass="requiredAtr" />
									<h:outputLabel value=":" />
								</h:panelGroup>
								<h:inputText value="#{updateAdmissionController.model.patient.firstName}"/>
								<h:outputLabel value="Middle Name:" />
								<h:inputText value="#{updateAdmissionController.model.patient.middleName}"/>
								<h:panelGroup>	
									<h:outputLabel value="Last Name" />
									<h:outputLabel value="*" styleClass="requiredAtr" />
									<h:outputLabel value=":" />
								</h:panelGroup>							
								<h:inputText value="#{updateAdmissionController.model.patient.lastName}"/>							
								<h:outputLabel value="Medical Problem"/>
								<rich:comboBox  value="#{updateAdmissionController.model.medicalProblem}"
												suggestionValues="#{medicalProblemDao.all}"
												converter="#{medicalProblemConverter}"
												enableManualInput="true"/>
								<h:outputLabel value="Case Number"/>				
								<h:inputText size="5" value="#{updateAdmissionController.model.caseNo}"/>							
							</h:panelGrid>
				</rich:panel>
					<rich:panel styleClass="patientPanelCls" style="border:0px;">
						<f:facet name="header">
							<h:outputText value="Photograph" />
						</f:facet>
						<h:panelGrid columns="1">
							<h:commandLink value="Click" onclick="launchChildW(); return false;" rendered="#{ empty updateAdmissionController.model.patient.photo}" />
							<h:outputLink onclick="launchChildW(); return false;" disabled="#{ not empty updateAdmissionController.model.patient.photo}">							
								<h:graphicImage id="imgctrl22" style="border: thin solid gray" width="240px" height="180px" url="#{ empty updateAdmissionController.model.patient.photo ? fn:concat('/bss/images/clicked2?dummy=',admissionController.random) : fn:concat('/bss/images/saved?id=',updateAdmissionController.model.patient.id) }"/>
							</h:outputLink>
						</h:panelGrid>												
					</rich:panel>		
					<rich:panel style="vertical-align: top;border:0">
						<f:facet name="header">
							<h:outputText value="Material Set"/>
						</f:facet>
						<rich:dataGrid value="#{updateAdmissionController.model.materialAllocations}" var="materialAllocation" columns="2" style="border:0px" rowClasses="rc11" columnClasses="rc11">
							<h:panelGrid columns="2" columnClasses="rc14">
								<h:outputLabel value="#{materialAllocation.materialType.name}"/>
								<h:inputText size="1" value="#{materialAllocation.instances}" style="margin-right: 5px;" onkeyup="validateInteger(this,true,'Only numbers allowed !');" />
							</h:panelGrid>
						</rich:dataGrid>
					</rich:panel>
					<rich:panel style="border:0">
				<f:facet name="header">
					<h:outputText value="Utensil Set"/>
				</f:facet>
				<h:panelGrid columns="3" width="100%" >							
						<h:outputLabel value="Utensils Set:"/>
						<rich:comboBox  value="#{updateAdmissionController.model.materialSet}"
										suggestionValues="#{admissionController.materialSetList}"
										converter="#{materialSetConverter}"
										enableManualInput="true"									
										width="100">
										<a4j:support event="onchange" action="#{updateAdmissionController.updateUtensilDeposit}" reRender="utensilSetPanel,utensilDepositAmount" limitToList="true"														
														status="uscost"/>
						</rich:comboBox>
						<a4j:status forceId="true" id="uscost" >
							 <f:facet name="start">
				                  <h:graphicImage value="/images/im1.gif"/>
				             </f:facet>
						</a4j:status>
						<h:outputLabel value="Utensil Deposit: "/>
						<h:inputText id="utensilDepositAmount" value="#{updateAdmissionController.utensilDeposit}"/>
				</h:panelGrid>
				<h:panelGroup id="utensilSetPanel">
					<h:outputText value="Items: " />												
					<rich:dataGrid value="#{updateAdmissionController.model.materialSet.materialSetMappings}" var="materialSetMapping" columns="2" style="border:0px" rowClasses="rc11" columnClasses="rc11">
						<h:panelGrid columns="2">
							<h:outputLabel value="#{materialSetMapping.materialType.name}"/>
							<h:outputText value="(#{materialSetMapping.instances})" style="margin-right: 10px;"/>
						</h:panelGrid>
					</rich:dataGrid>							
				</h:panelGroup>		
			</rich:panel>
	</h:panelGrid>
	
		<table width="100%" >
			<tr>
				<td valign="top" align="right">					
					<h:commandButton 	action="#{updateAdmissionController.update}" 
										value="Update"	id="id11"	 style="display: #{updateAdmissionController.model.id eq 0 ? 'none':'block'}"																
										onclick="showLoading();"/>
				</td>
				<td valign="top" align="left">
					<h:commandButton 	action="#{updateAdmissionController.cancel}" id="id22"
										value="Cancel" style="display: #{updateAdmissionController.model.id eq 0 ? 'none':'block'}"
										onclick="showLoading();"/>			
				</td>
			</tr>	
	</table>
	
</h:form>	
		
	
	
	
	
	</ui:define>
</ui:composition>